""" System imports """
import logging

""" Other modules """

""" Game """

""" Constants """
DIRECTION_UP = 0
DIRECTION_DOWN = 1
DIRECTION_LEFT = 2
DIRECTION_RIGHT = 3

""" Set up logging """
_log = logging.getLogger("equinox.events")

class Event:
    """ Superclass for any events that are managed by the EventRouter """
    def __init__(self):
        self.name = "Generic Event"
        
class SystemEvent(Event):
    """ Superclass for all system events """

    def __init__(self):
        self.name = "Generic System Event"
        
class GameEvent(Event):
    """ Superclass for all game events """

    def __init__(self):
        self.name = "Generic Game Event"
        
class GUIEvent(Event):
    """ Superclass for all GUI events """

    def __init__(self):
        self.name = "Generic GUI Event"
        
""" --- System Events -------------------------------------------------------- """

class TickEvent(SystemEvent):
    """ CPU Tick event """    
    def __init__(self):
        self.name = "CPU Tick Event"
        
        
class QuitEvent(SystemEvent):
    """ Fires when the player wants to quit """
        
    def __init__(self):
        self.name = "Quit Event"

class KeyPressedEvent(SystemEvent):
    """ Fires when a key is pressed """
    
    def __init__(self, event):
        self.name = "Key pressed event"
        self.key = event.key
        self.pyEvent = event
        
class KeyReleasedEvent(SystemEvent):
    """ Fires when a key is released """
    
    def __init__(self, event):
        self.name = "Key released event"
        self.key = event.key
        self.pyEvent = event
        
class MouseButtonPressedEvent(SystemEvent):
    """ Fires when a mouse button is pressed """
    
    def __init__(self, event):
        self.name = "Mouse button pressed event"
        self.button = event.button
        self.pos = event.pos
        self.pyEvent = event
        
class MouseButtonReleasedEvent(SystemEvent):
    """ Fires when a mouse button is released """
    
    def __init__(self, event):
        self.name = "Mouse button released event"
        self.button = event.button
        self.pos = event.pos
        self.pyEvent = event
        
class MouseMovedEvent(SystemEvent):
    """ Fires when the mouse moves """
    
    def __init__(self, event):
        self.name = "Mouse moved event"
        self.rel = event.rel
        self.pos = event.pos
        self.buttons = event.buttons
        self.pyEvent = event

class MapBuiltEvent(SystemEvent):
    """ Fires when the map is done building/loading """            
    def __init__(self, map):
        self.name = "Map Built Event"
        self.map = map
                
class GameStartedEvent(SystemEvent):
    """ Fires when the game has started """
    def __init__(self, game):
        self.name = "Game Started Event"
        self.game = game
                
class GameStartRequest(SystemEvent):
    """ Fires when we want to start the game """
    def __init__(self, game):
        self.name = "Game start request"
        self.game = game
        
class CharacterMoveRequest(SystemEvent):
    """ Fires when the character wishes to move """
    def __init__(self, direction):
        self.name = "Character Move Request"
        self.direction = direction
        
class CharacterPlaceEvent(SystemEvent):
    """ Fires when a player is /placed/ in a sector 
        (they didn't move from another sector) """
    def __init__(self, character):
        self.name = "Character Placed Event"
        self.character = character
        
class CharacterPlaceRequest(SystemEvent):
    """..."""
    def __init__(self, player, charactor, sector):
        self.name = "Character Placement Request"
        self.player = player
        self.charactor = charactor
        self.sector = sector

class ExceptionEvent(SystemEvent):
    """..."""
    def __init__(self, msg):
        self.name = "An exception occurred that we can handle"
        self.msg = msg
        
""" --- Game Events -------------------------------------------------------- """
class CharacterMoveEvent(GameEvent):
    """ Fires when the player moves """
    def __init__(self, character):
        self.name = "Character Move Event"
        self.character = character
        
        
""" --- GUI Events -------------------------------------------------------- """

class GUIFocusThisWidgetEvent(GUIEvent):
    """ Fires when a widget gets focus """
    
    def __init__(self):
        self.name = "GUI Focus This Widget Event"
        
class GUIFocusNextWidgetEvent(GUIEvent):
    """..."""
    def __init__(self, layer=0):
        self.name = "Activate the next widget Event"
        self.layer = layer

class GUIFocusPrevWidgetEvent(GUIEvent):
    """..."""
    def __init__(self, layer=0):
        self.name = "Activate the previous widget Event"
        self.layer = layer

class GUIPressEvent(GUIEvent):
    """..."""
    def __init__(self, layer=0):
        self.name = "All Active widgets get pressed Event"
        self.layer = layer

class GUIKeyEvent(GUIEvent):
    """..."""
    def __init__(self, key, layer=0):
        self.name = "key pressed Event"
        self.key = key
        self.layer = layer

class GUIControlKeyEvent(GUIEvent):
    """..."""
    def __init__(self, key):
        self.name = "Non-Printablekey pressed Event"
        self.key = key

class GUIClickEvent(GUIEvent):
    """..."""
    def __init__(self, pos, layer=0):
        self.name = "Mouse Click Event"
        self.pos = pos
        self.layer = layer

class GUIMouseMoveEvent(GUIEvent):
    """..."""
    def __init__(self, pos, layer=0):
        self.name = "Mouse Moved Event"
        self.pos = pos
        self.layer = layer

class GUICharacterSelectedEvent(GUIEvent):
    """..."""
    def __init__(self, charactor, wipeOthers=1):
        self.name = "A Character has been selected by the user"
        self.charactor = charactor
        self.wipeOthers = wipeOthers


class GUICharacterUnSelectedEvent(GUIEvent):
    """..."""
    def __init__(self, charactor):
        self.name = "A Character has been unselected by the user"
        self.charactor = charactor

class GUIChangeScreenRequest(GUIEvent):
    """..."""
    def __init__(self, key):
        self.name = "Change the active GUI to the one referenced by key"
        self.key = key


class GUIDialogAddRequest(GUIEvent):
    """..."""
    def __init__(self, key, msg):
        self.name = "Add a new dialog on top"
        self.key = key
        self.msg = msg

class GUIDialogRemoveRequest(GUIEvent):
    """..."""
    def __init__(self, key):
        self.name = "Remove a new dialog from the top"
        self.key = key
        
